package com.irain.pp.tool.exception;

import java.util.Random;

/**
 * @author WangYanPeng
 * @date 2017/11/14 12:40
 */
public class RandomUtils {

    private RandomUtils(){}

    private static final char[] CHARS = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();

    public static String genRandomNumber(int length){
        Random random = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(10);
            sb.append(CHARS[26 + number]);
        }
        return sb.toString();
    }

    public static String genRandomTextCaseInsensitive(int length){
        Random random = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(36);
            sb.append(CHARS[number]);
        }
        return sb.toString();
    }
}
